/*!
 * FileName: luogu-2573.cpp
 * This Problem is on luogu. The ID of the problem is 2573. 
 * Copyright(c) 2019 Shu_Yu_Mo
 * MIT Licensed
 * Luogu: https://www.luogu.org/space/show?uid=44615
 * Github: https://github.com/oldsuold/
 * Gitee: https://gitee.com/Shu_Yu_Mo/
 * These words were created by an amazing tool written by Shu_Yu_Mo.
 */
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstring>
#include<iostream>
#include<cmath>
#include<vector>
#include<queue>
#include<algorithm>
#define inf 0x7fffffff
#define int long long
using namespace std;
const int _N = 100100;
const int _M = 1000100;
inline int read()
{
    char c = getchar(); int sign = 1; int x = 0;
    while(c > '9' || c < '0') { if(c=='-')sign = -1; c = getchar(); } 
    while(c <= '9' && c >= '0') { x *= 10; x += c - '0'; c = getchar(); }
    return x * sign;
}
struct edges{
	int node;
	int w;
	int nxt;
}edge[_M << 1];
int tot = 0;
int head[_N];
void add(int u, int v, int w)
{
	edge[++tot].nxt = head[u];
	edge[tot].node = v;
	edge[tot].w = w;
	head[u] = tot;
}
struct  Ew{
	int u;
	int v;
	int w;
	int h;
	inline bool operator < (const Ew A) const {
		if(h == A.h)
			return w < A.w;
		else
			return h > A.h;
	}
}_edge[_M];
int totE = 0;
int H[_N];
bool vis[_N];
int sum = 0;
void Shu_Yu_Mo_Jia_You(int k)
{
	sum ++;
	vis[k] = true;
	for(register int i = head[k];i;i = edge[i].nxt)
	{
		int &node = edge[i].node;
		_edge[++totE].u = k;
		_edge[totE].v = node;
		_edge[totE].w = edge[i].w;
		_edge[totE].h = H[node];
		if(!vis[node]) Shu_Yu_Mo_Jia_You(node);
	}
}

int F[_N];
void init(int n) { for(register int i = 1;i <= n;i++) F[i] = i; }
int find(int x) { return F[x] == x ? x : F[x] = find(F[x]); }
void marge(int x, int y) { x = find(x);y = find(y);if(x == y) return; F[x] = y; }
int ask(int x, int y) { return find(x) == find(y); }

signed main()
{
	memset(vis, false, sizeof(vis));
	int n = read(), m = read();
	for(register int i = 1;i <= n;i++) H[i] = read();
	for(register int i = 1;i <= m;i++)
	{
		int tmpx = read(), tmpy = read(), tmpz = read();
		if(H[tmpx] >= H[tmpy]) add(tmpx, tmpy, tmpz);
		if(H[tmpx] <= H[tmpy]) add(tmpy, tmpx, tmpz);
	}
	Shu_Yu_Mo_Jia_You(1);
	sort(_edge + 1, _edge + 1 + totE);
	init(n);
	int ans = 0;
	for(register int i = 1;i <= totE;i++)
	{
		Ew & now = _edge[i];
//		printf("#%d %d %d %d\n", now.u, now.v,now.w,now.h);
		if(!ask(now.u, now.v))
		{
//			printf("marge %d %d\n", now.u, now.v);
			marge(now.u, now.v);
			ans += now.w;
		}
	}
	printf("%lld %lld", sum, ans);
    return 0;
}
